package org

/** Main package for O/R Broker. */
package object orbroker {
  
  import java.io.{Reader,LineNumberReader}
  private[orbroker] implicit def readerToIterator(reader: Reader): Iterator[String] = {
    val lnr = 
      if (reader.isInstanceOf[LineNumberReader])
        reader.asInstanceOf[LineNumberReader]
      else
        new LineNumberReader(reader)
    new Iterator[String] {
      var n: String = lnr.readLine
      override def hasNext = {
        n != null
      }
      override def next = {
        val nn = n
        n = lnr.readLine
        nn
      }
    }
  }
  
  private val NO_ID = Symbol("<anonymous>")
  
  implicit def stringToReader(string: String) = new java.io.StringReader(string)
  implicit def sym2Token[T](id: Symbol): Token[T] = Token(id)
  implicit def sql2Token[T](sql: String): Token[T] = Token(sql, NO_ID)

}